//
//  UserAgreementViewController.swift
//  ZNZXSuperMarket
//
//  Created by 四川中农 on 2018/9/10.
//  Copyright © 2018年 四川中农. All rights reserved.
//

import UIKit
import WebKit

class UserAgreementViewController: BaseViewController {

    var url = ""
    var webView:WKWebView!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        self.title = "用户注册协议"
        
        self.webView = WKWebView.init(frame: CGRect.init(x: 0, y: 0, width: UIScreen.ScreenWidth, height: UIScreen.ScreenHeight - (Utils.isIphoneX() ? 88 : 64)), configuration: WKWebViewConfiguration.init())
        webView.allowsBackForwardNavigationGestures = true
        webView.navigationDelegate = self
        self.view.addSubview(webView)
        self.getArticleAgreement()
    }
    
    
    func getArticleAgreement(){
        PKhud.show()
        HttpRequest.requestData(.post, URLString: Api.articleAgreement.rawValue, parameters:nil ) { (result) in
            PKhud.hiden()
            if result["msg"] as! String == "success"{
                self.url = result["data"] as! String
                self.webView.load(URLRequest.init(url: URL.init(string: self.url)!))
            }else{
                PKhud.showText(text: result["data"] as! String)
            }
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

extension UserAgreementViewController:WKNavigationDelegate{
    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        PKhud.hiden()
    }
}


















